package com.candoit.webapps.pricing.bean.adapters;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;

import com.candoit.webapps.pricing.model.Maquina;

@ManagedBean(name = "maquinaadapter")
@ViewScoped
public class MaquinaAdapter extends GenericAdapter {

	@Override
	public List<SelectItem> getItems() {
		if (items == null){
			items = new ArrayList<SelectItem>();
            list = retrieve();
            for (Maquina m: (List<Maquina>)list ){
                items.add(new SelectItem(m, m.getNombre())); 
            }
        }
		
		return items;
	}

	@Override
	public String getClase() {
		return "Maquina";
	}

	@Override
	public String getFieldId() {
		return "id";
	}

	@Override
	public GenericConverter getConverter() {
		converter = new MaquinaConverter();
		converter.setClase(getClase());
		converter.setFieldId(getFieldId());
		return converter;		
	}

}
